<?php

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/
Route::middleware('auth:sanctum')->get('/user', function (Request $request) {
    return $request->user();
});
    //刷新token
    Route::post('/token/refresh',[App\Http\Controllers\TokenController::class,'refreshToken']);
    //小程序路由
    Route::get('/login',[App\Http\Controllers\Api\LoginController::class,'index'])->name('login');
    Route::post('/login',[App\Http\Controllers\Api\LoginController::class,'login']);
    Route::post('/wx/login',[App\Http\Controllers\WechatController::class,'login']);

    //获取首页得数据
    Route::get('/index',[App\Http\Controllers\Api\IndexController::class,'index']);
    //新闻
    Route::get('/news',[App\Http\Controllers\Api\NewsController::class,'lists']);
    Route::get('/news/detail',[App\Http\Controllers\Api\NewsController::class,'detail']);
    Route::post('/bind',[App\Http\Controllers\Api\UserController::class,'bind']);

    //产品详情
    Route::get('/product/info',[App\Http\Controllers\Api\ProductController::class,'info']);
     //产品列表
    Route::get('/product/lists',[App\Http\Controllers\Api\ProductController::class,'lists']);
    //产品分类
    Route::get('/category/lists',[App\Http\Controllers\Api\CategoryController::class,'lists']);
    Route::get('/category/simple',[App\Http\Controllers\Api\CategoryController::class,'simple']);
    Route::get('/category/product/lists',[App\Http\Controllers\Api\CategoryController::class,'productlists']);

    Route::group(['middleware'=>'auth:sanctum'],function(){

            //购物车详情
            Route::get('/cart/lists',[App\Http\Controllers\Api\CartController::class,'lists']);
            Route::get('/cart/info',[App\Http\Controllers\Api\CartController::class,'info']);
            Route::post('/cart/add',[App\Http\Controllers\Api\CartController::class,'add']);
            Route::post('/cart/del',[App\Http\Controllers\Api\CartController::class,'del']);


            //下单
            Route::post('/order/submit',[App\Http\Controllers\Api\OrderController::class,'submit']);
            //订单列表
            Route::post('/order/product/set',[App\Http\Controllers\Api\OrderController::class,'setCache']);
            Route::get('/order/product/get',[App\Http\Controllers\Api\OrderController::class,'getCache']);
            Route::get('/order/lists',[App\Http\Controllers\Api\OrderController::class,'lists']);

            Route::get('/order/info',[App\Http\Controllers\Api\OrderController::class,'info']);

            Route::post('/order/create',[App\Http\Controllers\Api\OrderController::class,'create']);
            Route::post('/order/edit',[App\Http\Controllers\Api\OrderController::class,'edit']);
            //个人信息
            Route::get('/user/info',[App\Http\Controllers\Api\UserController::class,'info']);
            Route::post('/user/address/add',[App\Http\Controllers\Api\AddressController::class,'create']);
            Route::post('/user/address/edit',[App\Http\Controllers\Api\AddressController::class,'update']);
            Route::post('/user/address/del',[App\Http\Controllers\Api\AddressController::class,'del']);
            Route::get('/user/address/default',[App\Http\Controllers\Api\AddressController::class,'userAddr']);
            Route::get('/user/address/list',[App\Http\Controllers\Api\AddressController::class,'userAddrList']);

    });


Route::group(['prefix'=>'test'],function(){
    Route::post('/product/test',[App\Http\Controllers\Admin\ProductController::class,'test']);
});
Route::group(['prefix'=>'admin'],function(){
    Route::post('/file/upload',[App\Http\Controllers\FileController::class,'upload']);
    Route::post('/login',[App\Http\Controllers\Admin\SiteController::class,'login']);
    //文章管理
        Route::get('/article/index',[App\Http\Controllers\Admin\ArticleController::class,'index']);
        Route::post('/article/create',[App\Http\Controllers\Admin\ArticleController::class,'create']);
        Route::post('/article/update',[App\Http\Controllers\Admin\ArticleController::class,'update']);
        Route::post('/article/del',[App\Http\Controllers\Admin\ArticleController::class,'del']);
        //文章分类
        Route::get('/article/category/index',[App\Http\Controllers\Admin\ArticleCategoryController::class,'index']);
        //新闻管理
        Route::get('/news/index',[App\Http\Controllers\Admin\NewsController::class,'index']);
        Route::post('/news/create',[App\Http\Controllers\Admin\NewsController::class,'create']);
        Route::post('/news/update',[App\Http\Controllers\Admin\NewsController::class,'update']);
        Route::post('/news/del',[App\Http\Controllers\Admin\NewsController::class,'del']);
        Route::get('/news/info',[App\Http\Controllers\Admin\NewsController::class,'info']);

    Route::group(['middleware'=>'token.role'],function(){
        //专区
        Route::get('/area/all',[App\Http\Controllers\Admin\AreaController::class,'all']);
        Route::get('/area/index',[App\Http\Controllers\Admin\AreaController::class,'index']);
        Route::post('/area/update',[App\Http\Controllers\Admin\AreaController::class,'update']);
        Route::post('/area/create',[App\Http\Controllers\Admin\AreaController::class,'create']);
        Route::post('/area/del',[App\Http\Controllers\Admin\AreaController::class,'del']);
        Route::post('/area/product/set',[App\Http\Controllers\Admin\AreaController::class,'updateProduct']);

        //订单
        Route::get('/order/index',[App\Http\Controllers\Admin\OrderController::class,'index']);
        Route::post('/order/create',[App\Http\Controllers\Admin\OrderController::class,'create']);
        Route::post('/order/edit',[App\Http\Controllers\Admin\OrderController::class,'edit']);
        Route::post('/order/del',[App\Http\Controllers\Admin\OrderController::class,'del']);
        Route::post('/order/send',[App\Http\Controllers\Admin\OrderController::class,'send']);
        Route::get('/order/detail',[App\Http\Controllers\Admin\OrderController::class,'detail']);
        //产品
        Route::get('/product/index',[App\Http\Controllers\Admin\ProductController::class,'index']);
        Route::post('/product/create',[App\Http\Controllers\Admin\ProductController::class,'create']);
        Route::post('/product/update',[App\Http\Controllers\Admin\ProductController::class,'update']);
        Route::post('/product/del',[App\Http\Controllers\Admin\ProductController::class,'del']);
        Route::get('/product/info',[App\Http\Controllers\Admin\ProductController::class,'info']);
        Route::post('/product/recommend',[App\Http\Controllers\Admin\ProductController::class,'recommend']);
        Route::post('/product/unrecommend',[App\Http\Controllers\Admin\ProductController::class,'unrecommend']);
        Route::post('/product/setup',[App\Http\Controllers\Admin\ProductController::class,'setup']);
        Route::post('/product/setdown',[App\Http\Controllers\Admin\ProductController::class,'setdown']);
        Route::post('/product/sku/create',[App\Http\Controllers\Admin\ProductController::class,'createSku']);
        //菜单
        Route::get('/menu/index',[App\Http\Controllers\Admin\MenuController::class,'index']);
        Route::post('/menu/add',[App\Http\Controllers\Admin\MenuController::class,'create']);
        Route::post('/menu/update',[App\Http\Controllers\Admin\MenuController::class,'edit']);
        Route::post('/menu/del',[App\Http\Controllers\Admin\MenuController::class,'del']);
        Route::get('/menu/all',[App\Http\Controllers\Admin\MenuController::class,'all']);

        //分类
        Route::get('/category/index',[App\Http\Controllers\Admin\CategoryController::class,'index']);
        Route::post('/category/create',[App\Http\Controllers\Admin\CategoryController::class,'create']);
        Route::post('/category/update',[App\Http\Controllers\Admin\CategoryController::class,'update']);
        Route::post('/category/del',[App\Http\Controllers\Admin\CategoryController::class,'del']);

        //管理员管理
        Route::get('/manager/all',[App\Http\Controllers\Admin\ManagerController::class,'all']);
        Route::post('/manager/add',[App\Http\Controllers\Admin\ManagerController::class,'add']);
        Route::post('/manager/del',[App\Http\Controllers\Admin\ManagerController::class,'del']);
        Route::post('/manager/edit',[App\Http\Controllers\Admin\ManagerController::class,'edit']);
        Route::post('/manager/pwd/edit',[App\Http\Controllers\Admin\ManagerController::class,'editPassword']);
        //角色管理
        Route::get('/role/all',[App\Http\Controllers\Admin\RoleController::class,'all']);
        Route::post('/role/create',[App\Http\Controllers\Admin\RoleController::class,'create']);
        Route::post('/role/update',[App\Http\Controllers\Admin\RoleController::class,'update']);
        Route::post('/role/permission/update',[App\Http\Controllers\Admin\RoleController::class,'updatePermission']);
        Route::post('/role/menu/update',[App\Http\Controllers\Admin\RoleController::class,'updateMenu']);

        //权限管理
        Route::get('/access/all',[App\Http\Controllers\Admin\AccessController::class,'all']);
        Route::get('/access/index',[App\Http\Controllers\Admin\AccessController::class,'index']);
        Route::post('/access/create',[App\Http\Controllers\Admin\AccessController::class,'create']);
        Route::post('/access/del',[App\Http\Controllers\Admin\AccessController::class,'del']);
        Route::post('/access/edit',[App\Http\Controllers\Admin\AccessController::class,'edit']);
        //轮播图
        Route::get('/banner/all',[App\Http\Controllers\Admin\BannerController::class,'all']);
        Route::get('/banner/index',[App\Http\Controllers\Admin\BannerController::class,'index']);
        Route::post('/banner/create',[App\Http\Controllers\Admin\BannerController::class,'create']);
        Route::post('/banner/del',[App\Http\Controllers\Admin\BannerController::class,'del']);
        Route::post('/banner/edit',[App\Http\Controllers\Admin\BannerController::class,'edit']);
        //用户
        Route::get('/user/index',[App\Http\Controllers\Admin\UserController::class,'index']);
        Route::post('/user/update',[App\Http\Controllers\Admin\UserController::class,'update']);

        //配置
        Route::get('/config/all',[App\Http\Controllers\Admin\ConfigController::class,'all']);
        Route::get('/config/index',[App\Http\Controllers\Admin\ConfigController::class,'index']);
        Route::post('/config/create',[App\Http\Controllers\Admin\ConfigController::class,'create']);
        Route::post('/config/update',[App\Http\Controllers\Admin\ConfigController::class,'store']);
        Route::get('/config/group/index',[App\Http\Controllers\Admin\ConfigController::class,'group']);
        Route::get('/config/group/del',[App\Http\Controllers\Admin\ConfigController::class,'delGroup']);
        Route::get('/config/group/create',[App\Http\Controllers\Admin\ConfigController::class,'createGroup']);
    });

});
